package com.lyl.label.controller;

import cn.hutool.core.collection.ListUtil;
import com.lyl.label.common.exception.LabelException;
import com.lyl.label.common.result.Result;
import com.lyl.label.common.result.ResultCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/getStr")
    public String getStr() {
        return "hello,world";
    }

    @GetMapping("/getList")
    public Result<List<String>> getList() {
        return Result.ok(ListUtil.of("中国加油", "世界皆有"));
    }

    @GetMapping("/getInt")
    public Integer getInt() {
        return 1;
    }

    @GetMapping("/getInt2")
    public Integer getInt2() {
        int i = 1 / 0;
        return i;
    }

    @GetMapping("/getInt3")
    public Integer getInt3(){
        throw new LabelException(ResultCode.DEMO_SERVICE_EXCEPTION);
    }
}
